/*******************************************************************************
//// 
Author:    Neil Malhotra and Jake Jares
Date:      2021.09.10

Inputs:    "Survey Respondent Data for Regression Analyses.dta"
Ouputs:    Regression Tables
		       * table_3.tex
		       * table_4.tex
			   * table_5.tex
			   * table_6.tex
			   * table_a3.tex, table_a4.tex, table_a5.tex, 
			     table_a6.tex, table_a7.tex, table_a8.tex
			   * table_a9.tex
			   * table_a10.tex, table_a11.tex
			   * table_a12.tex, table_a13.tex, table_a14.tex
			   * table_fsi2
*******************************************************************************/


#delimit;
clear; capture log close; macro drop _all; program drop _all; set more off; 
set type double; set varabbrev off;
#delimit cr

// CHANGE THE FOLLOWING FILEPATH TO REFLECT LOCATION OF REPLICATION FOLDER
// (Note that Windows machines use "\" characters for filepaths)
global PROJECT_DIR "/Users/jjares/Documents/research/Farm Subsidies/replication_materials"
global DATA "${PROJECT_DIR}/data"
cd "${PROJECT_DIR}/tables"

use "${DATA}/Survey Respondent Data for APSR Analyses.dta", clear
keep if complete

/* Table 3 MFP effects  */

* Table 3, column 1
reg mfp_support mfp_any conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_3.tex, dec(3) replace label

* Table 3, column 2
reg mfp_support mfp_total_cnt conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_3.tex, dec(3) append label

* Table 3, column 3
reg mfp_support mfp_quintile conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_3.tex, dec(3) append label

* Table 3, column 4
reg gov_avg mfp_any conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_3.tex, dec(3) append label

/* Table 4 MFP heterogeneity by ideology */

* Table 4, column 1
reg mfp_support mfp_any conservative conservative_mfp_any military gender age education total_acres farm_value_2019, robust
outreg2 using table_4.tex, dec(3) replace label

* Table 4, column 2
reg mfp_support mfp_total_cnt conservative conservative_mfp_total_cnt military gender age education total_acres farm_value_2019, robust
outreg2 using table_4.tex, dec(3) append label

* Table 4, column 3
reg mfp_support mfp_quintile conservative conservative_mfp_quintile military gender age education total_acres farm_value_2019, robust
outreg2 using table_4.tex, dec(3) append label

* Table 4, column 4
reg gov_avg mfp_any conservative conservative_mfp_any military gender age education total_acres farm_value_2019, robust
outreg2 using table_4.tex, dec(3) append label


* Table 5 ARC/PLC
* Table 5, column 1
reg arc_support arc_quintile conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_5.tex, dec(3) replace label

* Table 5, column 2
reg arc_support arc_quintile conservative conservative_arc_quintile military gender age education  total_acres farm_value_2019, robust
outreg2 using table_5.tex, dec(3) append label

* Table 5, column 3 (experiment)
reg arc_support arctreat conservative military gender age education  total_acres farm_value_2019 if arctreat==1|controltreat==1, robust
outreg2 using table_5.tex, dec(3) append label

* Table 5, column 4 (experiment)
reg arc_support arctreat conservative conservative_arctreat military gender age education  total_acres farm_value_2019 if arctreat==1|controltreat==1, robust
outreg2 using table_5.tex, dec(3) append label

lincom arctreat + conservative_arctreat

* Table 5, column 5 (experiment)
reg trump_approve arctreat conservative military gender age education  total_acres farm_value_2019 if arctreat==1|controltreat==1, robust
outreg2 using table_5.tex, dec(3) append label

* Table 5, column 6
reg gov_avg arc_quintile conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_5.tex, dec(3) append label

* Table 5, column 7
reg gov_avg arc_quintile conservative conservative_arc_quintile military gender age education  total_acres farm_value_2019, robust
outreg2 using table_5.tex, dec(3) append label 


/* Table 6 CRP  */

* Table 6, column 1
reg crp_support crp_quintile conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_6.tex, dec(3) replace label

* Table 6, column 2
reg crp_support crp_quintile conservative conservative_crp_quintile military gender age education  total_acres farm_value_2019, robust
outreg2 using table_6.tex, dec(3) append label

* Table 6, column 3 (experiment)
reg crp_support crptreat conservative military gender age education  total_acres farm_value_2019 if crptreat==1|controltreat==1, robust
outreg2 using table_6.tex, dec(3) append label

* Table 6, column 4 (experiment)
reg crp_support crptreat conservative conservative_crptreat   ///
military gender age education  total_acres farm_value_2019 if crptreat==1|controltreat==1, robust
outreg2 using table_6.tex, dec(3) append label

lincom crptreat + conservative_crptreat

* Table 6, column 5 (experiment)
reg trump_approve crptreat conservative military gender age education  total_acres farm_value_2019 if crptreat==1|controltreat==1, robust
outreg2 using table_6.tex, dec(3) append label

* Table 6, column 6
reg gov_avg crp_quintile conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_6.tex, dec(3) append label

* Table 6, column 7
reg gov_avg crp_quintile conservative conservative_crp_quintile military gender age education  total_acres farm_value_2019, robust
outreg2 using table_6.tex, dec(3) append label


/* Online Appendix */

/* By components of government support index */

* Online Appendix Table 3 (MFP part 1)

reg gov_helped mfp_any conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a3.tex, dec(2) replace label

foreach var of varlist gov_opps gov_trust gov_waste fair_share deficit gov_society {
	reg `var' mfp_any conservative military gender age education total_acres farm_value_2019, robust
	outreg2 using table_a3.tex, dec(2) append label
}

* Online Appendix Table 4 (MFP part 2)

reg gov_disasters mfp_any conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a4.tex, dec(2) replace label

foreach var of varlist gov_specinterests gov_distress gov_environ gov_medical gov_retire gov_eat {
	reg `var' mfp_any conservative military gender age education total_acres farm_value_2019, robust
	outreg2 using table_a4.tex, dec(2) append label
}

* Online Appendix Table 5 (ARC part 1)

reg gov_helped arc_quintile conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a5.tex, dec(2) replace label

foreach var of varlist gov_opps gov_trust gov_waste fair_share deficit gov_society {
	reg `var' arc_quintile conservative military gender age education total_acres farm_value_2019, robust
	outreg2 using table_a5.tex, dec(2) append label
}

* Online Appendix Table 6 (ARC part 2)

reg gov_disasters arc_quintile conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a6.tex, dec(2) replace label

foreach var of varlist gov_specinterests gov_distress gov_environ gov_medical gov_retire gov_eat {
	reg `var' arc_quintile conservative military gender age education total_acres farm_value_2019, robust
	outreg2 using table_a6.tex, dec(2) append label
}

* Online Appendix Table 7 (CRP part 1)

reg gov_helped crp_quintile conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a7.tex, dec(2) replace label

foreach var of varlist gov_opps gov_trust gov_waste fair_share deficit gov_society {
	reg `var' crp_quintile conservative military gender age education total_acres farm_value_2019, robust
	outreg2 using table_a7.tex, dec(2) append label
}

* Online Appendix Table 8 (CRP part 2)

reg gov_disasters crp_quintile conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a8.tex, dec(2) replace label

foreach var of varlist gov_specinterests gov_distress gov_environ gov_medical gov_retire gov_eat {
	reg `var' crp_quintile conservative military gender age education total_acres farm_value_2019, robust
	outreg2 using table_a8.tex, dec(2) append label
}

/* By binary party ID instead of ideology */

* Online Appendix Table 9

* Online Appendix Table 9, column 1
reg mfp_support mfp_any republican republican_mfp_any military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a9.tex, dec(3) replace label

* Online Appendix Table 9, column 2
reg mfp_support mfp_total_cnt republican republican_mfp_total_cnt military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a9.tex, dec(3) append label

* Online Appendix Table 9, column 3
reg mfp_support mfp_quintile republican republican_mfp_quintile military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a9.tex, dec(3) append label

* Online Appendix Table 9, column 4
reg mfp_support mfp_any ideology ideology_mfp_any military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a9.tex, dec(3) append label

* Online Appendix Table 9, column 5
reg mfp_support mfp_total_cnt ideology ideology_mfp_total_cnt military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a9.tex, dec(3) append label

* Online Appendix Table 9, column 6
reg mfp_support mfp_quintile ideology ideology_mfp_quintile military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a9.tex, dec(3) append label


/* Do the observational effects vary by experimental condition? */

*Table A10 (MFP)


* Online Appendix Table 10, column 1
reg mfp_support mfp_any arctreat crptreat mfp_any_arctreat mfp_any_crptreat conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a10.tex, dec(3) replace label

* Online Appendix Table 10, column 2
reg mfp_support mfp_total_cnt arctreat crptreat mfp_total_cnt_arctreat mfp_total_cnt_crptreat conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a10.tex, dec(3) append label

* Online Appendix Table 10, column 3
reg mfp_support mfp_quintile arctreat crptreat mfp_quintile_arctreat mfp_quintile_crptreat  conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a10.tex, dec(3) append label

* Online Appendix Table 10, column 4
reg gov_avg mfp_any arctreat crptreat mfp_any_arctreat mfp_any_crptreat  conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a10.tex, dec(3) append label


* Online Appendix Table 11 (ARC/PLC and CRP)


* Online Appendix Table 11, column 1
reg arc_support arc_quintile arctreat crptreat arc_quintile_arctreat arc_quintile_crptreat conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a11.tex, dec(3) replace label

* Online Appendix Table 11, column 2
reg gov_avg arc_quintile arctreat crptreat arc_quintile_arctreat arc_quintile_crptreat conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a11.tex, dec(3) append label

* Online Appendix Table 11, column 3
reg crp_support crp_quintile arctreat crptreat crp_quintile_arctreat crp_quintile_crptreat  conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a11.tex, dec(3) append label

* Online Appendix Table 11, column 4
reg gov_avg crp_quintile arctreat crptreat crp_quintile_arctreat crp_quintile_crptreat  conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a11.tex, dec(3) append label

* Online Appendix Table 12 (MFP Quintiles Constructed From Complete Responses)

* Online Appendix Table 12, column 1
reg mfp_support mfp_quintile_alt conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_a12.tex, dec(3) replace label

* Online Appendix Table 12, column 2
reg mfp_support mfp_quintile_alt conservative conservative_mfp_quintile_alt military gender age education total_acres farm_value_2019, robust
outreg2 using table_a12.tex, dec(3) append label


* Online Appendix Table 13 (ARC/PLC Quintiles Constructed from Complete Responses)

* Online Appendix Table 13, column 1
reg arc_support arc_quintile_alt conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a13.tex, dec(3) replace label

* Online Appendix Table 13, column 2
reg arc_support arc_quintile_alt conservative_arc_quintile_alt conservative  military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a13.tex, dec(3) append label

* Online Appendix Table 13, column 3
reg gov_avg arc_quintile_alt conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a13.tex, dec(3) append label

* Online Appendix Table 13, column 4
reg gov_avg arc_quintile_alt conservative_arc_quintile_alt conservative  military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a13.tex, dec(3) append label

* Online Appendix Table 14 (CRP Quintiles Constructed from Complete Responses)

* Online Appendix Table 14, column 1
reg crp_support crp_quintile_alt conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a14.tex, dec(3) replace label

* Online Appendix Table 14, column 2
reg crp_support crp_quintile_alt conservative_crp_quintile_alt conservative  military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a14.tex, dec(3) append label

* Online Appendix Table 14, column 3
reg gov_avg crp_quintile_alt conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a14.tex, dec(3) append label

* Online Appendix Table 14, column 4
reg gov_avg crp_quintile_alt conservative_crp_quintile_alt conservative  military gender age education  total_acres farm_value_2019, robust
outreg2 using table_a14.tex, dec(3) append label

/* Further Supplemental Information */

* Further Supplemental Information Table 2 (validation of farmer identity question)

reg mfp_support identity_farmer, robust
outreg2 using table_fsi2.tex, dec(3) replace label

reg mfp_support identity_farmer mfp_any  conservative military gender age education total_acres farm_value_2019, robust
outreg2 using table_fsi2.tex, dec(3) append label

reg arc_support identity_farmer, robust
outreg2 using table_fsi2.tex, dec(3) append label

reg arc_support identity_farmer arc_quintile conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_fsi2.tex, dec(3) append label

reg crp_support identity_farmer, robust
outreg2 using table_fsi2.tex, dec(3) append label

reg crp_support identity_farmer crp_quintile conservative military gender age education  total_acres farm_value_2019, robust
outreg2 using table_fsi2.tex, dec(3) append label

































